package com.fwtai.api.controller;

import com.fwtai.config.ConfigFile;
import com.fwtai.entity.ReqPage;
import com.fwtai.service.api.ApiShareService;
import com.fwtai.tool.ToolClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 分享推广控制层|路由层[api]
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @创建日期 2021-09-14 11:46:52
 * @官网 <url>http://www.fwtai.com</url>
 */
@RestController
@Api(tags = "分享|推广有礼,token必填",description = "分享赚佣金")
@RequestMapping(ConfigFile.api_v10 +"share")
public class ShareController{

  @Resource
  private ApiShareService apiShareService;

  /**获取我的邀请码*/
  @ApiOperation(value = "获取我的邀请码", notes = "通过当前登录人获取自己的邀请码")
  @GetMapping("/queryCode")
  public void queryCode(final HttpServletResponse response){
    ToolClient.responseJson(apiShareService.queryCode(null),response);
  }

  /**
   * 分页查询分享团队
  */
  @ApiOperation(value = "查询我的分享|推广团队", notes = "获取的分享|推广团队的数据,其中level表示是级别。<br/>level=1是通过我的邀请码注册的;level=2是通过我的下级分享的邀请码注册的")
  @GetMapping("listDataPage")
  public void listDataPage(final ReqPage reqPage,final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(apiShareService.listDataPage(request),response);
  }

  @ApiOperation(value = "查询是否是合伙人", notes = "查询是否是合伙人,code=200时说明是合伙人")
  @GetMapping("getIdentity")
  public void getIdentity(final HttpServletResponse response){
    ToolClient.responseJson(apiShareService.getIdentity());
  }

  @ApiOperation(value = "获取我的直接客户的邀请人数详情列表", notes = "获取我的直接客户的邀请人数详情列表,不含总人数,获取总人数的接口是getMyTotal")
  @GetMapping("getMyTeamList")
  public void getMyTeamList(final ReqPage reqPage,final HttpServletRequest request,final HttpServletResponse response){
    ToolClient.responseJson(apiShareService.getMyTeamList(request),response);
  }

  @ApiOperation(value = "获取我的邀请直接客户人数", notes = "获取我的邀请直接客户人数，替换接口 listReferrerUser的总人数")
  @GetMapping("getMyTotal")
  public void getMyTotal(final HttpServletResponse response){
    ToolClient.responseJson(apiShareService.getMyTotal(),response);
  }

  @ApiOperation(value = "获取我的邀请人", notes = "我的邀请人信息")
  @GetMapping("getMyInviter")
  public void getMyInviter(final HttpServletResponse response){
    ToolClient.responseJson(apiShareService.getMyInviter(),response);
  }
}